home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1998 November: Tool Chest / Dev.CD Nov 98 TC.toast / Sample Code / Toolbox / Live Scroll 1.0 / Sources / Menus.c < prev    next >
Encoding:
C/C++ Source or Header  |  1996-05-13  |  1.6 KB  |  124 lines  |  [TEXT/CWIE]

  1. /*
  2.     File:        Menus.c
  3.  
  4.     Contains:    Handles the application's menus
  5.  
  6.     Written by:    Chris White, Developer Technical Support
  7.     
  8.     Copyright:    © 1996 by Apple Computer, Inc., all rights reserved.
  9.     
  10.     Change History (most recent first):
  11.     
  12.             03/29/96            CW        First release
  13.  
  14. */
  15.  
  16.  
  17. #pragma segment Core
  18.  
  19.  
  20. #ifndef __MENUS__
  21.     #include <Menus.h>
  22. #endif
  23.  
  24. #ifndef __WINDOWS__
  25.     #include <Windows.h>
  26. #endif
  27.  
  28. #ifndef __DIALOGS__
  29.     #include <Dialogs.h>
  30. #endif
  31.  
  32. #ifndef __TEXTUTILS__
  33.     #include <TextUtils.h>
  34. #endif
  35.  
  36. #ifndef __DESK__
  37.     #include <Desk.h>
  38. #endif
  39.  
  40.  
  41.  
  42.  
  43.  
  44. // Application includes
  45.  
  46. #ifndef __BAREBONES__
  47.     #include "BareBones.h"
  48. #endif
  49.  
  50. #ifndef __PROTOTYPES__
  51.     #include "Prototypes.h"
  52. #endif
  53.  
  54.  
  55.  
  56.  
  57. static void DoAppleCmds ( SInt16 theItem );
  58. static void DoFileCmds ( SInt16 theItem );
  59.  
  60.  
  61.  
  62.  
  63.  
  64. void MenuDispatch ( SInt32 menuResult )
  65. {
  66.     SInt16     theMenu = (menuResult >> 16);                    // menu selected
  67.     SInt16     theItem = (menuResult & 0x0000FFFF);               // item selected
  68.     
  69.     switch (theMenu)
  70.     {
  71.         case kAppleMenu: 
  72.             DoAppleCmds ( theItem );
  73.         break;
  74.         
  75.         case kFileMenu: 
  76.             DoFileCmds ( theItem );
  77.         break;
  78.         
  79.     }
  80.     
  81.     HiliteMenu ( 0 );               // un-hilite selected menu
  82.     
  83.     return;
  84.     
  85. } // MenuDispatch
  86.  
  87.  
  88.  
  89. static void DoAppleCmds ( SInt16 theItem )
  90. {
  91.     Str255    name;            // string for DA name
  92.     
  93.     
  94.     switch ( theItem )
  95.     {
  96.         case cAbout:
  97.             DoAboutBox ( );
  98.         break;
  99.         
  100.         default:
  101.             GetItem ( GetMHandle ( kAppleMenu ), theItem, (StringPtr) &name );
  102.             OpenDeskAcc ( (StringPtr) &name );
  103.         break;
  104.     }
  105. }
  106.  
  107.  
  108.  
  109. static void DoFileCmds ( SInt16 theItem )
  110. {    
  111.     switch ( theItem )
  112.     {
  113.         case cQuit:
  114.             gQuit = true;
  115.         break;
  116.     }
  117.     
  118.     return;
  119.     
  120. } // DoFileCmds
  121.  
  122.  
  123.  
  124.